/**
 * 
 */
package com.lmm.test;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.lmm.db.DBCon;

/**
 * @author leiming
 *
 */
public class ReadBlob {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String sql ="select s.shop_id,s.shop_content from cfg_shops_info s where s.shop_member_id =100383";
		DBCon db = new DBCon();
		ResultSet rs=null;
		try {
		 rs = db.executeQuery(sql);
		 	while(rs.next()) {
			  int  shopId = rs.getInt("shop_id");
			  System.out.println(shopId);
			  InputStream in = rs.getBinaryStream("shop_content");
			  InputStreamReader ir = new InputStreamReader(in);
			  BufferedReader br = new BufferedReader(ir);
			  StringBuffer sb = new StringBuffer();
			  String line = null;
			  while((line =br.readLine())!=null) {
				  sb.append(line);
			  }
			  System.out.println(sb.toString());
			  br.close();
			  ir.close();
			  in.close();
		 	}
		}catch (SQLException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				rs.close();
			} catch (SQLException e) {
			}
			db.close();
		}
	}

}
